package com.neusoft.yuejian_6.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.neusoft.yuejian_6.adapter.ShowAdapter;

import com.neusoft.yuejian_6.R;
import com.neusoft.yuejian_6.javabean.Show;
import com.neusoft.yuejian_6.model.ShowModel;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;


public class ShowFragment  extends Fragment {
    private RecyclerView recyclerView;
    private View view = null;
    private ImageView s_pic;
    private ImageView s_pic2;
    private TextView s_content;
    private TextView s_address;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.tab04, container, false);
        recyclerView = (RecyclerView) view.findViewById(R.id.rv);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));//设置布局
        initView();
        getData();
        return view;
    }
    private void initView()
    {
        s_content= (TextView) view.findViewById(R.id.s_content);
        s_address= (TextView) view.findViewById(R.id.s_content);
        s_pic= (ImageView) view.findViewById(R.id.s_pic);
        s_pic2= (ImageView) view.findViewById(R.id.s_pic2);

    }




    //获取列表数据
    private void getData() {
        ShowModel showModel=new ShowModel();
        Call<List<Show>> call=showModel.getShowlist();
        // System.out.print("t_name");
        call.enqueue(new Callback<List<Show>>() {
            @Override
            public void onResponse(Call<List<Show>> call, Response<List<Show>> response) {
                List<Show> data = response.body();  //获取数据
                System.out.printf("data");
                recyclerView.setAdapter(new ShowAdapter(ShowFragment.this.getActivity(), data));
            }
            @Override
            public void onFailure(Call<List<Show>> call, Throwable t) {

            }
        });



    }


}



